/*
Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.

The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <sstream>
#include "print.h"
using namespace std;

/**
* Definition for binary tree*/


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}

void testForIntToString()
{
	int a = 10;
	stringstream ss;
	ss << a;
	string str = ss.str();
	cout << str << endl;

	string str1 = to_string(a);

}






class Solution {
public:
	int minDepth(TreeNode *root) {
		if (root == NULL)
		{
			return 0;
		}
		else if (root->right == NULL)
		{
			return minDepth(root->left) + 1;
		}
		else if (root->left == NULL)
		{
			return minDepth(root->right) + 1;

		}
		else
		{
			int m = minDepth(root->left);
			int n = minDepth(root->right);
			return min(m, n) + 1;
		}

	}
};

int main(int argc, char* argv[])
{



	for (int i = 1; i < argc; i++){


		cout << argv[i] << endl;

	}

	int A[] = { 1, 2, 3, 0, 0 };
	int B[] = { 2, 4 };
	//cout << << endl;
	stack<int> st, st2;
	st.push(1);
	st.push(2);


	vector<vector<int> > levelInt(0);
	//stack<TreeNode*> stackTree;
	//vector<int> intVec;
	//intVec.push_back(1);
	//levelInt.push_back(intVec);


	TreeNode *p = new TreeNode(1);

	TreeNode *left = new TreeNode(2);
	TreeNode *right = new TreeNode(3);
	TreeNode *left1 = new TreeNode(4);
	TreeNode *right1 = new TreeNode(5);


	p->left = left;
	p->right = right;
	p->left->left = left1;
	p->left->right = NULL;
	p->right->right = right1;
	p->right->left = NULL;

	Solution s;
	//stackTree.push(p->left);
	//stackTree.push(p->right);
	//cout << " The longest path:" << s.maxDepth(p) << endl;

	system("pause");
	return 0;
}